﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace API.Models.Repository
{
    public class SEC_USER_COMPANIES_Repository : GenericRepository<PartnerDbContext, SEC_USER_COMPANIES>
    {
        public override IQueryable<SEC_USER_COMPANIES> Find(System.Linq.Expressions.Expression<Func<SEC_USER_COMPANIES, bool>> predicate)
        {
            IQueryable<SEC_USER_COMPANIES> query = _entities.SEC_USER_COMPANIES
                .Include("COMPANY");

            /// Фильтрация по заданному условию
            if (predicate != null)
                query = query.Where(predicate);

            if (session != null)
            {
                query = query
                    .Where(r => r.USER_GUID == this.session.USER_GUID)
                    .AsQueryable();
            }

            return query;
        }
    }
}